<template>
  <div>
    <a-layout>
      <div class="header-title-box">
        <div class="headerTitle">
          <div class="block" />
          <div class="title-info">社保</div>
        </div>
      </div>
      <!-- <div class="title-info-tishi">
        提示：默认个人缴纳基数需大于等于可选基数范围最小值
      </div> -->
      <!-- 新增合同类型 -->
      <a-modal title="总计尾数处理" :visible="editVisible" @ok="confirmAddType" @cancel="handleDialCancel">
        <div>
          <a-form :form="typeForm" :label-col="{ span: 7 }" :wrapper-col="{ span: 12 }" :colon="true">
            <a-form-item label="单位尾数处理">
              <a-select :value="isSheBao ? groupItemDefault : groupItemDefault2" @change="weiShuHandleChange">
                <a-select-option v-for="(group, index) in groupList" :key="index" :value="group.id">
                  {{ group.name }}
                </a-select-option>
              </a-select>
            </a-form-item>
            <a-form-item label="个人尾数处理">
              <a-select :value="isSheBao ? GgroupItemDefault : GgroupItemDefault2" @change="GweiShuHandleChange">
                <a-select-option v-for="(group, index) in groupList" :key="index" :value="group.id">
                  {{ group.name }}
                </a-select-option>
              </a-select>
            </a-form-item>
          </a-form>
        </div>
      </a-modal>

      <!-- 编辑社保方案 -->
      <a-row>
        <a-form :form="form">
          <a-table :data-source="shebaoNewList" :pagination="false" row-key="defaultType" :columns="columns">
            <span v-if="record.defaultType < 200" slot="itemName" slot-scope="text, record">{{ text }}</span>
            <a-form-item
              v-else
              slot="itemName"
              slot-scope="text, record, index"
              style="margin-bottom: 0px"
              :validate-status="text.length > 0 ? 'success' : 'error'"
              :help="text.length > 0 ? '' : '必填项'"
            >
              <a-input
                placeholder="项目名称"
                style="width: 100px"
                :value="record.itemName"
                @change="(e) => handleName(e, record, index, shebaoNewList)"
              />
            </a-form-item>
            <span slot="customTitle" class="addCursor">
              <span @click="handleItemShow">
                <span style="margin-right: 5px">项目</span>
                <a-icon type="plus-circle" />
              </span>

              <div v-if="itemShow" class="checkboxWrapper">
                <a-checkbox-group v-model="itemChecked" @change="handleCheckbox">
                  <a-row>
                    <a-col :span="40">
                      <a-checkbox value="101"> 养老保险 </a-checkbox>
                    </a-col>
                    <a-col :span="40">
                      <a-checkbox value="103"> 失业保险 </a-checkbox>
                    </a-col>
                    <a-col :span="24">
                      <a-checkbox value="104"> 工伤保险 </a-checkbox>
                    </a-col>

                    <a-col :span="40">
                      <a-checkbox value="106"> 企业(职业)年金 </a-checkbox>
                    </a-col>
                    <a-col :span="40">
                      <a-checkbox value="107"> 商业健康保险 </a-checkbox>
                    </a-col>
                    <a-col :span="40">
                      <a-checkbox value="108"> 税延养老保险 </a-checkbox>
                    </a-col>
                    <a-col :span="40">
                      <a-checkbox value="109"> 补充养老保险 </a-checkbox>
                    </a-col>

                    <a-col :span="40">
                      <a-checkbox value="111"> 残保金 </a-checkbox>
                    </a-col>
                  </a-row>
                </a-checkbox-group>
                <a-divider />
                <span @click="() => addOtherItem(1)">
                  <a-icon type="plus-circle" />
                  <span style="margin-left: 5px">其他项目</span>
                </span>
              </div>
            </span>

            <a-form-item slot="cardinalityDefault" slot-scope="text, record" style="width: 0px; margin-bottom: 0px" v-show="false">
              <a-input-number
                :value="record.cardinalityDefault"
                :min="record.cardinalityMin"
                :max="record.cardinalityMax"
                :precision="2"
                @change="(value) => handleDefault(value, record)"
              />
            </a-form-item>
            <a-form-item slot="action" slot-scope="text, record" style="margin-bottom: 0px">
              <a-input-number
                :value="(record.cardinalityDefault = record.cardinalityMin)"
                :min="0"
                :max="record.cardinalityMax"
                :precision="2"
                @change="(value) => handleMin(value, record)"
                style="width: 100px"
              />
              —
              <a-input-number
                :value="record.cardinalityMax"
                :min="record.cardinalityMin"
                :max="99999"
                :precision="2"
                @change="(value) => handleMax(value, record)"
                style="width: 100px"
              />
            </a-form-item>
            <a-form-item slot="persentCompany" slot-scope="text, record" style="margin-bottom: 0px">
              <a-input-number
                :value="record.persentCompany"
                :min="0"
                :max="100"
                :formatter="(value) => `${value}` + '%'"
                @blur="blurhandleCompany(record)"
                @change="(value) => handleCompany(value, record)"
                style="width: 100px"
              />
            </a-form-item>
            <a-form-item slot="persentPersonal" slot-scope="text, record" style="margin-bottom: 0px">
              <a-input-number
                :disabled="record.itemName === '工伤保险'"
                :min="0"
                :max="100"
                :value="record.persentPersonal"
                :formatter="(value) => `${value}` + '%'"
                @blur="blurhandlePersonal(record)"
                @change="(value) => handlePersonal(value, record)"
                style="width: 100px"
              />
            </a-form-item>
            <span slot="amountCompany" slot-scope="text, record">{{ getCompanyAmount(groupItemDefault, record) }}</span>
            <span slot="amountPersonal" slot-scope="text, record">{{ getPersonAmount(GgroupItemDefault, record) }}</span>
            <span
              slot="delete"
              slot-scope="text, record"
              style="cursor: pointer"
              class="primary_color"
              @click="deleteShebaoItem(record, 1)"
            >
              删除
            </span>
          </a-table>
        </a-form>
        <div class="header-title-box" style="margin-top: 50px">
          <div class="headerTitle">
            <div class="block" />
            <div class="title-info">医保</div>
          </div>
        </div>
        <a-form :form="form" style="margin-top: 20px">
          <a-table :data-source="yibaoNewList" :pagination="false" row-key="defaultType" :columns="columns">
            <span v-if="record.defaultType < 200" slot="itemName" slot-scope="text, record">{{ text }}</span>
            <a-form-item
              v-else
              slot="itemName"
              slot-scope="text, record, index"
              style="margin-bottom: 0px"
              :validate-status="text.length > 0 ? 'success' : 'error'"
              :help="text.length > 0 ? '' : '必填项'"
            >
              <a-input
                placeholder="项目名称"
                style="width: 100px"
                :value="record.itemName"
                @change="(e) => handleName(e, record, index, yibaoNewList)"
              />
            </a-form-item>
            <span slot="customTitle" class="addCursor">
              <span @click="handleItemShow3">
                <span style="margin-right: 5px">项目</span>
                <a-icon type="plus-circle" />
              </span>

              <div v-if="itemShow3" class="checkboxWrapper">
                <a-checkbox-group v-model="itemChecked2" @change="handleCheckbox2">
                  <a-row>
                    <a-col :span="40">
                      <a-checkbox value="102"> 医疗保险 </a-checkbox>
                    </a-col>
                    <a-col :span="40">
                      <a-checkbox value="105"> 生育保险 </a-checkbox>
                    </a-col>

                    <a-col :span="40">
                      <a-checkbox value="110"> 补充(大病医疗)保险 </a-checkbox>
                    </a-col>
                  </a-row>
                </a-checkbox-group>
                <a-divider />
                <span @click="() => addOtherItem(3)">
                  <a-icon type="plus-circle" />
                  <span style="margin-left: 5px">其他项目</span>
                </span>
              </div>
            </span>
            <a-form-item slot="cardinalityDefault" slot-scope="text, record" style="width: 0px; margin-bottom: 0px" v-show="false">
              <a-input-number
                :value="record.cardinalityDefault"
                :min="record.cardinalityMin"
                :max="record.cardinalityMax"
                :precision="2"
                @change="(value) => handleDefault(value, record)"
              />
            </a-form-item>
            <a-form-item slot="action" slot-scope="text, record" style="margin-bottom: 0px">
              <a-input-number
                :value="(record.cardinalityDefault = record.cardinalityMin)"
                :min="0"
                :max="record.cardinalityMax"
                :precision="2"
                @change="(value) => handleMin(value, record)"
                style="width: 100px"
              />
              —
              <a-input-number
                :value="record.cardinalityMax"
                :min="record.cardinalityMin"
                :max="99999"
                :precision="2"
                @change="(value) => handleMax(value, record)"
                style="width: 100px"
              />
            </a-form-item>
            <a-form-item slot="persentCompany" slot-scope="text, record" style="margin-bottom: 0px">
              <a-input-number
                :value="record.persentCompany"
                :min="0"
                :max="100"
                :formatter="(value) => `${value}` + '%'"
                @blur="blurhandleCompany(record)"
                @change="(value) => handleCompany(value, record)"
                style="width: 100px"
              />
            </a-form-item>
            <a-form-item slot="persentPersonal" slot-scope="text, record" style="margin-bottom: 0px">
              <a-input-number
                :disabled="record.itemName === '生育保险'"
                :min="0"
                :max="100"
                :value="record.persentPersonal"
                :formatter="(value) => `${value}` + '%'"
                @blur="blurhandlePersonal(record)"
                @change="(value) => handlePersonal(value, record)"
                style="width: 100px"
              />
            </a-form-item>
            <span slot="amountCompany" slot-scope="text, record">{{ getCompanyAmount(groupItemDefault, record) }}</span>
            <span slot="amountPersonal" slot-scope="text, record">{{ getPersonAmount(GgroupItemDefault, record) }}</span>
            <span
              slot="delete"
              slot-scope="text, record"
              style="cursor: pointer"
              class="primary_color"
              @click="deleteShebaoItem(record, 2)"
            >
              删除
            </span>
          </a-table>
        </a-form>

        <div class="totalBox">
          <div class="company" style="display: flex">
            <div class="text">社保单位总计：</div>
            <div class="number">{{ getCompanyAll() }}</div>
            <div style="margin-left: 10px; cursor: pointer; color: #000" @click="comZong">
              <a-icon type="edit" style="fontsize: 20px" />
            </div>
          </div>
          <div class="person" style="display: flex">
            <div class="text">社保个人总计：</div>
            <div class="number">{{ getPersonAll() }}</div>
            <div style="margin-left: 10px; cursor: pointer; color: #000" @click="comZong">
              <a-icon type="edit" style="fontsize: 20px" />
            </div>
          </div>
        </div>
      </a-row>
      <!-- 编辑公积金方案 -->
      <a-row>
        <a-row class="header-title">
          <div class="title-info">
            公积金
            <a-checkbox v-model="jijinShow" style="margin-left: 24px; margin-right: 5px" @change="jijinShowChange">不缴公积金</a-checkbox>
          </div>
        </a-row>
        <!-- <div class="title-info-tishi">
          提示：默认个人缴纳基数需大于等于可选基数范围最小值
        </div> -->
        <a-row v-if="!jijinShow">
          <a-table :data-source="jijin" :pagination="false" row-key="defaultType" :columns="columns">
            <span v-if="record.defaultType < 200" slot="itemName" slot-scope="text, record">{{ text }}</span>
            <a-form-item
              v-else
              slot="itemName"
              slot-scope="text, record, index"
              style="margin-bottom: 0px"
              :validate-status="text.length > 0 ? 'success' : 'error'"
              :help="text.length > 0 ? '' : '必填项'"
            >
              <a-input
                placeholder="项目名称"
                style="width: 100px"
                :value="record.itemName"
                @change="(e) => handleName(e, record, index, jijin)"
              />
            </a-form-item>
            <span slot="customTitle" class="addCursor">
              <span @click="handleItemShow2">
                <span style="margin-right: 5px">项目</span>
                <a-icon type="plus-circle" />
              </span>
              <div v-if="itemShow2" class="checkboxWrapper">
                <a-row>
                  <a-col :span="40">
                    <a-checkbox v-model="jijinChecked" @change="handleJijinCheckbox"> 公积金 </a-checkbox>
                  </a-col>
                  <a-col :span="40">
                    <a-checkbox v-model="jijinChecked2" @change="handleJijinCheckbox2"> 补充公积金 </a-checkbox>
                  </a-col>
                </a-row>
                <a-divider />
                <span @click="() => addOtherItem(2)">
                  <a-icon type="plus-circle" />
                  <span style="margin-left: 5px">其他项目</span>
                </span>
              </div>
            </span>
            <a-form-item slot="cardinalityDefault" slot-scope="text, record" style="margin-bottom: 0px; width: 0px" v-show="false">
              <a-input-number
                :value="record.cardinalityDefault"
                :min="record.cardinalityMin"
                :max="record.cardinalityMax"
                :precision="2"
                @change="(value) => handleDefault(value, record)"
              />
            </a-form-item>
            <a-form-item slot="action" slot-scope="text, record" style="margin-bottom: 0px">
              <a-input-number
                :value="(record.cardinalityDefault = record.cardinalityMin)"
                :min="0"
                :max="record.cardinalityMax"
                :precision="2"
                @change="(value) => handleMin(value, record)"
                style="width: 100px"
              />
              —
              <a-input-number
                :value="record.cardinalityMax"
                :min="record.cardinalityMin"
                :max="99999"
                :precision="2"
                @change="(value) => handleMax(value, record)"
                style="width: 100px"
              />
            </a-form-item>
            <a-form-item slot="persentCompany" slot-scope="text, record" style="margin-bottom: 0px">
              <a-input-number
                :value="record.persentCompany"
                :min="0"
                :max="100"
                @blur="blurhandleCompany(record)"
                :formatter="(value) => `${value}` + '%'"
                @change="(value) => handleCompany(value, record)"
                style="width: 100px"
              />
            </a-form-item>
            <a-form-item slot="persentPersonal" slot-scope="text, record" style="margin-bottom: 0px">
              <!-- record.itemName === '公积金' ? (record.persentPersonal = record.persentCompany) : record.persentPersonal -->
              <a-input-number
                :min="0"
                :max="100"
                :value="record.persentPersonal"
                @blur="blurhandlePersonal(record)"
                :formatter="(value) => `${value}` + '%'"
                @change="(value) => handlePersonal(value, record)"
                style="width: 100px"
              />
            </a-form-item>
            <span slot="amountCompany" slot-scope="text, record">{{ getCompanyAmount(groupItemDefault2, record) }}</span>
            <span slot="amountPersonal" slot-scope="text, record">{{ getPersonAmount(GgroupItemDefault2, record) }}</span>
            <span
              slot="delete"
              slot-scope="text, record"
              style="cursor: pointer"
              class="primary_color"
              @click="deleteShebaoItem(record, 3)"
            >
              删除
            </span>
          </a-table>
        </a-row>
        <!-- <a-row>
          <div class="totalBox">
            <div class="shebaoTotal">
              <span class="text">公积金单位总计：</span>
              <span class="number">{{ getPfCompanyAll() }}</span>
              <span class="icon" style="margin-left:10px;cursor:pointer;" @click="comGJZong">
                <a-icon type="edit" style="fontSize:20px;" />
              </span>
            </div>
            <div class="sfTotal">
              <span class="text">公积金个人总计：</span>
              <span class="number">{{ getPfPersonAll() }}</span>
              <span class="icon" style="margin-left:10px;cursor:pointer;" @click="comGJZong">
                <a-icon type="edit" style="fontSize:20px;" />
              </span>
            </div>
          </div>
        </a-row> -->
        <div class="totalBox">
          <div class="company" style="display: flex">
            <div class="text">公积金单位总计：</div>
            <div class="number">{{ getPfCompanyAll() }}</div>
            <div style="margin-left: 10px; cursor: pointer; color: #000" @click="comGJZong">
              <a-icon type="edit" style="fontsize: 20px" />
            </div>
          </div>
          <div class="person" style="display: flex">
            <div class="text">公积金个人总计：</div>
            <div class="number">{{ getPfPersonAll() }}</div>
            <div style="margin-left: 10px; cursor: pointer; color: #000" @click="comGJZong">
              <a-icon type="edit" style="fontsize: 20px" />
            </div>
          </div>
        </div>
      </a-row>

      <a-divider dashed />
      <a-row>
        <div class="totalBox2">
          <div class="company">
            <span class="text">社保总计：</span>
            <span class="number">{{ getPfCompanyAll2() }}</span>
          </div>
          <div class="person">
            <span class="text">公积金总计：</span>
            <span class="number">{{ getPfPersonAll2() }}</span>
          </div>
        </div>
      </a-row>
    </a-layout>
    <!-- 保存修改时跳出modal -->
    <a-modal :visible="isEnter" title="修改确认" @cancel="handleCancel" @ok="handleOk">
      <div class="fw500 fs18">模板修改后，创建未来新账单时将自动根据修改后的方案进行生成，请选择以前的未归档账单是否更新</div>
      <div class="fs16 mt12">缴纳基数和比例是否更新</div>
      <div class="mt16">
        <a-radio-group v-model="ChangeInfo" @change="handleChangeInfo">
          <a-radio :value="1">不更新未归档账单的缴纳基数和比例</a-radio>
          <a-radio :value="2">同步更新所有未归档账单中的缴纳基数和比例</a-radio>
        </a-radio-group>
      </div>
      <!-- <div v-if="isTimeShow" style="margin-top:20px;">
        <a-select mode="multiple" placeholder="请选择要更改的时间" style="width:300px" @change="handleTime">
          <a-select-option v-for="item in timeList" :key="item">{{ item }}</a-select-option>
        </a-select>
      </div> -->
    </a-modal>
    <div
      style="
        width: 85%;
        height: 50px;
        display: flex;
        justify-content: center;
        position: fixed;
        bottom: 20px;
        align-items: center;
        background: #ffffff;
        z-index: 1;
      "
    >
      <a-button @click="unSaveMethod">取消</a-button>
      <a-button type="primary" @click="saveMethod" style="margin-left: 20px">保存</a-button>
    </div>
  </div>
</template>

<script>
import { selectTimeInfoByProgId, selectAllEmpFiled } from "@/api/shebao/shebaoInfo.js";
import { changeShebaoMethod, findSocProgRelation, toWeiShuquire, getShebaoMethod } from "@/api/shebao/shebaoMethod.js";
import { isContainByString } from "@/utils/index";
const columns = [
  {
    dataIndex: "itemName",
    key: "itemName",
    slots: { title: "customTitle" },
    // title: '项目',
    scopedSlots: { customRender: "itemName" }
  },
  {
    title: "",
    dataIndex: "cardinalityDefault",
    key: "cardinalityDefault",
    scopedSlots: { customRender: "cardinalityDefault" }
  },
  {
    title: "可选基数范围",
    dataIndex: "action",
    key: "action",
    scopedSlots: { customRender: "action" }
  },
  {
    title: "单位缴纳比例",
    key: "persentCompany",
    dataIndex: "persentCompany",
    scopedSlots: { customRender: "persentCompany" }
  },
  {
    title: "个人缴纳比例",
    key: "persentPersonal",
    dataIndex: "persentPersonal",
    scopedSlots: { customRender: "persentPersonal" }
  },
  {
    title: "单位金额",
    dataIndex: "amountCompany",
    key: "amountCompany",
    scopedSlots: { customRender: "amountCompany" }
  },
  {
    title: "个人金额",
    dataIndex: "amountPersonal",
    key: "amountPersonal",
    scopedSlots: { customRender: "amountPersonal" }
  },
  {
    title: "操作",
    key: "delete",
    scopedSlots: { customRender: "delete" }
  }
];
const recordSample = {
  amountCompany: 0,
  amountPersonal: 0,
  cardinalityDefault: 0,
  cardinalityMax: 99999,
  cardinalityMin: 0,
  itemName: "养老保险",
  itemType: 1,
  persentCompany: 0,
  persentPersonal: 0,
  sort: 0,
  defaultType: 101
};

const initShebao = [
  {
    amountCompany: 0,
    amountPersonal: 0,
    cardinalityDefault: 0,
    cardinalityMax: 99999,
    cardinalityMin: 0,
    itemName: "养老保险",
    itemType: 1,
    persentCompany: 0,
    persentPersonal: 0,
    sort: 0,
    defaultType: 101
  },
  {
    amountCompany: 0,
    amountPersonal: 0,
    cardinalityDefault: 0,
    cardinalityMax: 99999,
    cardinalityMin: 0,
    itemName: "医疗保险",
    itemType: 3,
    persentCompany: 0,
    persentPersonal: 0,
    sort: 1,
    defaultType: 102
  },
  {
    amountCompany: 0,
    amountPersonal: 0,
    cardinalityDefault: 0,
    cardinalityMax: 99999,
    cardinalityMin: 0,
    itemName: "失业保险",
    itemType: 1,
    persentCompany: 0,
    persentPersonal: 0,
    sort: 2,
    defaultType: 103
  },
  {
    amountCompany: 0,
    amountPersonal: 0,
    cardinalityDefault: 0,
    cardinalityMax: 99999,
    cardinalityMin: 0,
    itemName: "工伤保险",
    itemType: 1,
    persentCompany: 0,
    persentPersonal: 0,
    sort: 3,
    defaultType: 104
  },
  {
    amountCompany: 0,
    amountPersonal: 0,
    cardinalityDefault: 0,
    cardinalityMax: 99999,
    cardinalityMin: 0,
    itemName: "生育保险",
    itemType: 3,
    persentCompany: 0,
    persentPersonal: 0,
    sort: 4,
    defaultType: 105
  }
];

const initJijin = [
  {
    amountCompany: 0,
    amountPersonal: 0,
    cardinalityDefault: 0,
    cardinalityMax: 99999,
    cardinalityMin: 0,
    itemName: "公积金",
    itemType: 2,
    persentCompany: 0,
    persentPersonal: 0,
    sort: 0,
    defaultType: 106
  }
];

export default {
  name: "ShebaoTable",

  props: {
    progId: {
      type: String,
      default: ""
    },
    progName: {
      type: String,
      default: ""
    },
    deductionsDate: {
      type: Number,
      default: 1
    },
    servercost: {
      type: Number,
      default: 0
    },
    socAccount: {
      type: String,
      default: ""
    },
    meAccount: {
      type: String,
      default: ""
    },
    pfAccount: {
      type: String,
      default: ""
    },
    socCity: {
      type: String,
      default: ""
    },
    socCityName: {
      type: String,
      default: ""
    }
  },
  data() {
    return {
      isContainByString,
      groupList: [
        { id: 1, name: "不处理" },
        { id: 2, name: "四舍五入到厘" },
        { id: 3, name: "四舍五入到分" },
        { id: 4, name: "四舍五入到角" },
        { id: 5, name: "四舍五入到元" },
        { id: 6, name: "四舍五入到小数点后四位" },
        { id: 7, name: "见厘进分" },
        { id: 8, name: "见分进角" },
        { id: 9, name: "见角进元" },
        { id: 10, name: "见厘舍去" },
        { id: 11, name: "见角舍去" },
        { id: 12, name: "见分舍去" }
      ],
      // 社保
      groupItemDefault: 3,
      GgroupItemDefault: 3,
      // 公积金
      groupItemDefault2: 3,
      GgroupItemDefault2: 3,

      isSheBao: true,

      editVisible: false,
      form: this.$form.createForm(this, { name: "editMethod" }),
      columns,
      onlySocAmount: false,
      jijinShow: false,
      itemShow: false,
      itemShow2: false,
      itemShow3: false,
      itemChecked: [], // checkbox当前值的数组
      itemChecked2: [],
      originChecked: [], // checkbox变化前选中的值的数组
      originChecked2: [],
      jijinChecked: false,
      jijinChecked2: false,
      recordSample,
      empCount: "",
      isEnter: false,
      ChangeInfo: 1,
      updateItem: false,
      isTimeShow: false,
      timeList: [],
      time: [],
      jijin: [],
      shebao: [],
      socProgItemDTOList: [],
      typeForm: this.$form.createForm(this),
      shebaoNewList: [],
      yibaoNewList: [],
      existList: []
    };
  },

  created() {
    this.toWeiShuquire();
    selectAllEmpFiled(this.isContainByString("contractAdmin") ? "0" : this.$store.state.hr.companyId).then((res) => {
      this.timeList = [];
      if (res.data != null) {
        this.existList = res.data;
      }
    });
    if (this.progId === "") {
      this.init(true);
      return;
    }
    this.toInquire();
  },
  methods: {
    getSheBao(index) {
      // return this.shebao;

      if (index === 1) {
        var tempShebao = [];
        for (var i in this.shebao) {
          // 遍历数组
          if (
            this.shebao[i].itemType ===
            1 /* .itemName !== "生育保险" && this.shebao[i].itemName !== "医疗保险" && this.shebao[i].itemName !== "补充(大病医疗)保险"*/
          ) {
            tempShebao.push(this.shebao[i]);
          }
        }
        // console.log(tempShebao);
        return tempShebao;
      } else {
        var tempYibao = [];
        for (var j in this.shebao) {
          // 遍历数组
          if (
            this.shebao[j].itemType ===
            3 /* "生育保险" || this.shebao[j].itemName === "医疗保险" || this.shebao[j].itemName === "补充(大病医疗)保险"*/
          ) {
            // this.shebao[j].itemType = 3;
            tempYibao.push(this.shebao[j]);
          }
        }
        return tempYibao;
      }
    },
    weiShuHandleChange(value) {
      console.log("++++++++" + value);
      if (this.isSheBao) {
        this.groupItemDefault = value;
      } else {
        this.groupItemDefault2 = value;
      }
    },
    GweiShuHandleChange(value) {
      console.log("========" + value);
      if (this.isSheBao) {
        this.GgroupItemDefault = value;
      } else {
        this.GgroupItemDefault2 = value;
      }
    },
    confirmAddType(e) {
      this.editVisible = false;
    },
    handleDialCancel() {
      this.editVisible = false;
    },
    comZong() {
      this.editVisible = true;
      this.isSheBao = true;
    },
    comGJZong() {
      this.editVisible = true;
      this.isSheBao = false;
    },
    getPfCompanyAll2() {
      let g = 0;
      if (this.getCompanyAll() + "".length >= this.getPersonAll() + "".length) {
        g = this.groupItemDefault;
      } else {
        g = this.GgroupItemDefault;
      }

      return this.calculationDot(g, NP.strip(parseFloat(this.getCompanyAll()) + parseFloat(this.getPersonAll())));
    },
    getPfPersonAll2() {
      let g = 0;
      if (this.getPfCompanyAll() + "".length >= this.getPfPersonAll() + "".length) {
        g = this.groupItemDefault2;
      } else {
        g = this.GgroupItemDefault2;
      }
      return this.calculationDot(g, NP.strip(parseFloat(this.getPfCompanyAll()) + parseFloat(this.getPfPersonAll())));
    },
    // //加法
    // accAdd(arg1,arg2){
    // var r1,r2,m;
    // try{r1=arg1.toString().split(".")[1].length}catch(e){r1=0}
    // try{r2=arg2.toString().split(".")[1].length}catch(e){r2=0}
    // m=Math.pow(10,Math.max(r1,r2))
    // return (arg1*m+arg2*m)/m
    // } ,
    // 初始化公积金数据
    jijinShowChange() {
      for (let i = this.jijin.length; i >= 0; i--) {
        this.jijin.splice(i, 1);
      }
      const record = {};
      for (const k in this.recordSample) {
        record[k] = recordSample[k];
      }
      record.defaultType = 106;
      record.itemName = "公积金";
      record.itemType = 2;
      this.jijin.push(record);
      this.jijinChecked = true;
      this.jijinChecked2 = false;
    },

    // 用于处理公积金checkbox变化后的一些逻辑
    handleJijinCheckbox() {
      const record = {};
      for (const k in this.recordSample) {
        record[k] = recordSample[k];
      }
      record.defaultType = 106;
      record.itemName = "公积金";
      record.itemType = 2;
      if (this.jijinChecked) {
        this.jijin.push(record);
        this.jijinChecked = true;
      } else {
        this.jijin.forEach((record, index) => {
          if (record.defaultType === 106) {
            this.deleteShebaoItem(record, 3);
          }
        });
      }
      this.resort(this.jijin);
    },

    handleJijinCheckbox2() {
      const record = {};
      for (const k in this.recordSample) {
        record[k] = recordSample[k];
      }
      record.defaultType = 107;
      record.itemName = "补充公积金";
      record.itemType = 2;
      if (this.jijinChecked2) {
        this.jijin.push(record);
        this.jijinChecked2 = true;
      } else {
        this.jijin.forEach((record, index) => {
          if (record.defaultType === 107) {
            this.deleteShebaoItem(record, 3);
          }
        });
      }
      this.resort(this.jijin);
    },
    // 给自定义项目设定序号
    setType(itemType) {
      if (itemType === 1 || itemType === 3) {
        let max = 300;
        this.shebao.forEach((item, index) => {
          if (item.defaultType > max) max = item.defaultType;
        });
        return max + 1;
      }
      if (itemType === 2) {
        let max = 400;
        this.jijin.forEach((item, index) => {
          if (item.defaultType > max) max = item.defaultType;
        });
        return max + 1;
      }
    },

    addOtherItem(itemType) {
      const record = {};
      for (const k in this.recordSample) {
        record[k] = recordSample[k];
      }
      record.itemName = "";
      record.itemType = itemType;
      if (itemType === 1 || itemType === 3) {
        record.defaultType = this.setType(itemType);
        this.shebao.push(record);

        this.shebaoNewList = this.getSheBao(1);
        this.yibaoNewList = this.getSheBao(2);
        this.resort(this.shebao);
      }
      if (itemType === 2) {
        record.defaultType = this.setType(2);
        this.jijin.push(record);

        this.resort(this.jijin);
      }
      // this.$message.success("添加成功");
    },
    // 选出两个数组中不同的元素，返回一个数组（因业务不需要，未考虑单个数组中有重复元素的情况）
    getArrDifference(arr1, arr2) {
      return arr1.concat(arr2).filter((v, i, arr) => {
        return arr.indexOf(v) === arr.lastIndexOf(v);
      });
    },
    // 用于处理社保checkbox变化后的一些逻辑
    handleCheckbox(values) {
      if (values.length < this.originChecked.length) this.reduceItem(values, 1);
      else this.addItem(values, 1);
    },
    handleCheckbox2(values) {
      if (values.length < this.originChecked2.length) this.reduceItem(values, 3);
      else this.addItem(values, 3);
    },
    // checkbox选中添加项目
    addItem(values, wich) {
      const arr = this.getArrDifference(wich === 1 ? this.originChecked : this.originChecked2, values);
      const type = parseInt(arr[0]);
      if (wich === 1) {
        this.originChecked = [];
        this.itemChecked.forEach((item, index) => {
          this.originChecked[index] = item;
        });
      } else if (wich === 3) {
        this.originChecked2 = [];
        this.itemChecked2.forEach((item, index) => {
          this.originChecked2[index] = item;
        });
      }

      const record = {};
      for (const k in this.recordSample) {
        record[k] = recordSample[k];
      }

      record.defaultType = type;
      if (type === 101) {
        record.itemName = "养老保险";
        record.itemType = wich;
      }
      if (type === 102) {
        record.itemName = "医疗保险";
        record.itemType = wich;
      }
      if (type === 103) {
        record.itemName = "失业保险";
        record.itemType = wich;
      }
      if (type === 104) {
        record.itemName = "工伤保险";
        record.itemType = wich;
      }
      if (type === 105) {
        record.itemName = "生育保险";
        record.itemType = wich;
      }
      if (type === 106) {
        record.itemName = "企业(职业)年金";
        record.itemType = wich;
      }
      if (type === 107) {
        record.itemName = "商业健康保险";
        record.itemType = wich;
      }
      if (type === 108) {
        record.itemName = "税延养老保险";
        record.itemType = wich;
      }
      if (type === 109) {
        record.itemName = "补充养老保险";
        record.itemType = wich;
      }
      if (type === 110) {
        record.itemName = "补充(大病医疗)保险";
        record.itemType = wich;
      }
      if (type === 111) {
        record.itemName = "残保金";
        record.itemType = wich;
      }
      this.shebao.push(record);
      this.shebaoNewList = this.getSheBao(1);
      this.yibaoNewList = this.getSheBao(2);
      this.resort(this.shebao);
      // this.$message.success("添加成功");
    },
    // checkbox取消选中减少项目
    reduceItem(values, wich) {
      const arr = this.getArrDifference(wich === 1 ? this.originChecked : this.originChecked2, values);
      if (wich === 1) {
        this.originChecked = [];
        this.itemChecked.forEach((item, index) => {
          this.originChecked[index] = item;
        });
      } else if (wich === 3) {
        this.originChecked2 = [];
        this.itemChecked2.forEach((item, index) => {
          this.originChecked2[index] = item;
        });
      }

      this.shebao.forEach((record, index) => {
        if (record.defaultType === parseInt(arr[0])) {
          this.deleteShebaoItem(record, wich);
        }
      });
    },

    handleItemShow() {
      this.itemShow = !this.itemShow;

      if (this.itemShow) {
        this.$emit("showMenu");
      }
    },
    handleItemShow2() {
      this.itemShow2 = !this.itemShow2;
      if (this.itemShow2) {
        this.$emit("showMenu");
      }
    },
    handleItemShow3() {
      this.itemShow3 = !this.itemShow3;
      if (this.itemShow3) {
        this.$emit("showMenu");
      }
    },
    hideItemShow() {
      this.itemShow = false;
      this.itemShow2 = false;
      this.itemShow3 = false;
    },
    // 删除社保或公积金项目
    deleteShebaoItem(record, wich) {
      const { sort, defaultType, itemType } = record;
      if (itemType === 1 || itemType === 3) {
        if (wich === 1) {
          this.itemChecked.forEach((item, index) => {
            if (parseInt(item) === defaultType) this.itemChecked.splice(index, 1);
          });
          this.originChecked.forEach((item, index) => {
            if (parseInt(item) === defaultType) {
              this.originChecked.splice(index, 1);
            }
          });
        } else if (wich === 2) {
          this.itemChecked2.forEach((item, index) => {
            if (parseInt(item) === defaultType) this.itemChecked2.splice(index, 1);
          });
          // console.log(this.itemChecked2);
          this.originChecked2.forEach((item, index) => {
            if (parseInt(item) === defaultType) {
              this.originChecked2.splice(index, 1);
            }
          });
        }

        this.shebao.splice(sort, 1);
        this.shebaoNewList = this.getSheBao(1);
        this.yibaoNewList = this.getSheBao(2);
        this.resort(this.shebao);
      }
      if (itemType === 2) {
        this.jijin.splice(sort, 1);
        if (defaultType === 106) this.jijinChecked = false;
        if (defaultType === 107) this.jijinChecked2 = false;
        this.resort(this.jijin);
        if (this.jijin.length === 0) {
          this.jijinShow = true;
        }
      }
      // this.$message.success("删除成功");
    },
    // 删除项目或添加项目以后重新排序，sort值代表一个项目在数组中的位置
    resort(arr) {
      if (arr != null) {
        arr.map((record, index) => {
          arr[index].sort = index;
        });
      }
    },

    handleName(e, record, index, newList) {
      for (var i = 0; i < this.existList.length; i++) {
        if (this.existList[i] === e.target.value) {
          const recordTemp = { ...record };
          recordTemp.itemName = "";
          const listTemp = [...newList];
          listTemp[index] = recordTemp;
          newList = listTemp;
          this.$message.error("社保子项,不可与入职模板或员工设置字段相同");
          return;
        }
      }

      const value = e.target.value;
      const { sort, itemType } = record;
      itemType === 1 || itemType === 3 ? (this.shebao[sort].itemName = value) : (this.jijin[sort].itemName = value);
    },
    // reg: 用于判断输入数据是否为非负数的数字的正则表达式
    handleDefault(value, record) {
      const { sort, itemType, cardinalityMin, cardinalityMax } = record;
      const reg = /^[+]{0,1}(\d+)$|^[+]{0,1}(\d+\.\d+)$/;
      if (reg.test(value) && value >= cardinalityMin && value <= cardinalityMax) {
        itemType === 1 || itemType === 3 ? (this.shebao[sort].cardinalityDefault = value) : (this.jijin[sort].cardinalityDefault = value);
      }
    },
    handleMin(value, record) {
      const { sort, itemType, cardinalityMax } = record;
      const reg = /^[+]{0,1}(\d+)$|^[+]{0,1}(\d+\.\d+)$/;
      if (reg.test(value) && value <= cardinalityMax) {
        itemType === 1 || itemType === 3 ? (this.shebao[sort].cardinalityMin = value) : (this.jijin[sort].cardinalityMin = value);
      }
    },
    handleMax(value, record) {
      const { sort, itemType, cardinalityMin } = record;
      const reg = /^[+]{0,1}(\d+)$|^[+]{0,1}(\d+\.\d+)$/;
      if (reg.test(value) && value >= cardinalityMin) {
        itemType === 1 || itemType === 3 ? (this.shebao[sort].cardinalityMax = value) : (this.jijin[sort].cardinalityMax = value);
      }
    },
    blurhandleCompany(record) {
      var h = (record.persentCompany + "").split(".");
      if (h.length > 1) {
        if (h[1].length > 4) {
          h[1] = h[1].substring(0, 4);
          record.persentCompany = parseFloat(h[0] + "." + h[1]);
        }
      }
      this.handleCompany(record.persentCompany, record);
    },
    handleCompany(value, record) {
      const persentPersonal = record.persentPersonal;
      const persentCompany = record.persentCompany;
      if (persentPersonal + persentCompany > 100) {
        this.$message.error("比例设置错误");
        record.persentCompany = 0;
      } else {
        const { sort, itemType } = record;
        const reg = /^[+]{0,1}(\d+)$|^[+]{0,1}(\d+\.\d+)$/;
        if (reg.test(value)) {
          itemType === 1 || itemType === 3 ? (this.shebao[sort].persentCompany = value) : (this.jijin[sort].persentCompany = value);
        }
      }
    },

    blurhandlePersonal(record) {
      var h = (record.persentPersonal + "").split(".");
      if (h.length > 1) {
        if (h[1].length > 4) {
          h[1] = h[1].substring(0, 4);
          record.persentPersonal = parseFloat(h[0] + "." + h[1]);
        }
      }
      this.handlePersonal(record.persentPersonal, record);
    },
    handlePersonal(value, record) {
      const { sort, itemType } = record;
      const persentPersonal = record.persentPersonal;
      const persentCompany = record.persentCompany;
      if (persentPersonal + persentCompany > 100) {
        this.$message.error("比例设置错误");
        record.persentPersonal = 0;
      } else {
        const reg = /^[+]{0,1}(\d+)$|^[+]{0,1}(\d+\.\d+)$/;
        if (reg.test(value)) {
          itemType === 1 || itemType === 3 ? (this.shebao[sort].persentPersonal = value) : (this.jijin[sort].persentPersonal = value);
        }
      }
    },
    // 计算单位金额
    getCompanyAmount(type, record) {
      return this.calculationDot(type, NP.strip(record.cardinalityDefault * record.persentCompany * 0.01));
    },
    // 计算个人金额
    getPersonAmount(type, record) {
      return this.calculationDot(type, NP.strip(record.cardinalityDefault * record.persentPersonal * 0.01));
    },
    // 计算小数点
    calculationDot(type, value) {
      switch (type) {
        case 0: // 不处理
          var s = value.toString().split(".");
          if (s.length === 1) {
            return s + ".00";
          } else {
            if (s[1].length === 1) {
              s[1] = s[1] + "0";
            }
            return s[0] + "." + s[1];
          }
        case 1: // 四舍五入到元
          return this.siWuDot(value, 0);
        case 2: // 四舍五入到角
          return this.siWuDot(value, 1);
        case 3: // 四舍五入到分
          return this.siWuDot(value, 2);
        case 4: // 四舍五入到厘
          return this.siWuDot(value, 3);
        case 5: // 四舍五入到小数点后4位
          return this.siWuDot(value, 4);
        case 6: // 见厘进分
          return this.jieQueDot(value, 2);
        case 7: // 见分进角
          return this.jieQueDot(value, 1);
        case 8: // 见角进元
          return this.jieQueDot(value, 0);
        case 9: // 见角舍去
          // console.log("yyyyyyy" + value + "/" + 1);
          return this.sheQuDot(value, 0);
        case 10: // 见分舍去
          return this.sheQuDot(value, 1);
        case 11: // 见厘舍去
          return this.sheQuDot(value, 2);
      }
    },
    // 四舍五入
    siWuDot(value, n) {
      var f = Math.round(value * Math.pow(10, n)) / Math.pow(10, n);
      var s = f.toString();
      var rs = s.indexOf(".");
      if (n !== 0 && rs < 0) {
        s += ".";
      }

      for (var i = s.length - s.indexOf("."); i <= n; i++) {
        s += "0";
      }
      if (n === 0) {
        s += ".00";
      }
      return s;
    },
    // 进1截取
    jieQueDot(value, t) {
      const f = value.toString();
      const s = f.split(".");
      if (s.length === 1) {
        return s + ".00";
      } else {
        if (t !== 0) {
          if (s[1].length > t) {
            const n = Number(s[1].substring(0, t));
            const n2 = n + 1;
            s[1] = n2.toString();
          } else if (s[1].length < t) {
            const c = t - s[1].length;
            for (var i = 0; i < c; i++) {
              s[1] += "0";
            }
          }
          return s[0] + "." + s[1];
        } else {
          const n = Number(s[0]) + 1;
          return n + ".00";
        }
      }
    },
    // 直接舍去
    sheQuDot(value, n) {
      const f = value.toString();
      const s = f.split(".");
      if (s.length === 1) {
        return s + ".00";
      } else {
        if (n !== 0) {
          if (s[1].length > n) {
            s[1] = s[1].substring(0, n);
          } else if (s[1].length < n) {
            const c = n - s[1].length;
            for (var i = 0; i < c; i++) {
              s[1] += "0";
            }
          }
          return s[0] + "." + s[1];
        } else {
          return s[0] + ".00";
        }
      }
    },

    // 计算单位和个人全部社保金额
    getCompanyAll() {
      let total = 0;
      if (this.shebao != null) {
        this.shebao.map((item) => {
          total += parseFloat(this.calculationDot(this.groupItemDefault, item.cardinalityDefault * item.persentCompany * 0.01));
        });
      }
      return this.calculationDot(this.groupItemDefault, NP.strip(total));
    },
    getPersonAll() {
      let total = 0;
      if (this.shebao != null) {
        this.shebao.map((item) => {
          if (item.itemType === 1 || item.itemType === 3) {
            total += parseFloat(this.calculationDot(this.GgroupItemDefault, item.cardinalityDefault * item.persentPersonal * 0.01));
          }
        });
      }

      return this.calculationDot(this.GgroupItemDefault, NP.strip(total));
    },
    // 计算单位和个人全部公积金金额
    getPfCompanyAll() {
      let total = 0;
      if (this.jijin != null) {
        this.jijin.map((item) => {
          if (item.itemType === 2) {
            total += parseFloat(this.calculationDot(this.groupItemDefault2, item.cardinalityDefault * item.persentCompany * 0.01));
          }
        });
      }

      return this.calculationDot(this.groupItemDefault2, NP.strip(total));
    },
    getPfPersonAll() {
      let total = 0;
      if (this.jijin != null) {
        this.jijin.map((item) => {
          total += parseFloat(this.calculationDot(this.GgroupItemDefault2, item.cardinalityDefault * item.persentPersonal * 0.01));
        });
      }

      return this.calculationDot(this.GgroupItemDefault2, NP.strip(total));
    },
    // 取消修改
    unSaveMethod() {
      this.$router.go(-1);
    },
    // 保存修改
    saveMethod() {
      const flag = this.judgeError();
      if (!flag) {
        this.$message.error("请检查参保城市、方案名称（最多50字）、或项目名称，缴费日期是否填写！");
        return;
      }
      this.checkProMonth();

      let goon = true;
      if (this.shebao) {
        console.log(this.groupItemDefault + "/" + this.GgroupItemDefault);
        this.shebao.map((item) => {
          item.mantissaProcCompany = this.groupItemDefault;
          item.mantissaProcPersonal = this.GgroupItemDefault;
          if (
            (item.itemName === "养老保险" || item.itemName === "医疗保险" || item.itemName === "失业保险") &&
            Number(item.cardinalityMin) === 0
          ) {
            this.$message.error(item.itemName + " 可选基数范围不允许是0！");
            goon = false;
            return;
          } else if (item.persentPersonal + item.persentCompany > 100) {
            this.$message.error(item.itemName + " 缴纳比例错误！");
            goon = false;
            return;
          }
        });
      }

      if (this.jijin) {
        if (!this.jijinShow) {
          this.jijin.map((item) => {
            item.mantissaProcCompany = this.groupItemDefault2;
            item.mantissaProcPersonal = this.GgroupItemDefault2;
            if (item.itemName === "公积金") {
              if (item.persentCompany < 0 || item.persentPersonal < 0) {
                this.$message.error("公积金比例不应为负数");
                goon = false;
                return;
              }
            }

            if (item.itemName === "公积金" && Number(item.cardinalityMin) === 0) {
              this.$message.error(item.itemName + " 可选基数范围不允许是0！");
              goon = false;
              return;
            } else if (item.persentPersonal + item.persentCompany > 100) {
              this.$message.error(item.itemName + " 缴纳比例错误！");
              goon = false;
              return;
            }
          });
        }
      }

      if (this.empCount > 0 && goon) {
        this.isEnter = true;
      } else if (this.empCount === 0) {
        this.isEnter = false;
        if (goon) {
          const newData = {
            socCity: this.socCity,
            socCityName: this.socCityName,
            progName: this.progName,
            companyId: this.isContainByString("contractAdmin") ? "0" : this.$store.state.hr.companyId,
            deductionsDate: this.deductionsDate,
            socProgItemDTOList: this.shebao.concat(this.jijin),
            onlySocAmount: false,
            payProvidentFund: this.jijinShow,
            serviceCost: this.servercost,
            socAccount: this.socAccount,
            meAccount: this.meAccount,
            pfAccount: this.pfAccount
          };
          if (this.progId === "") {
            var has = [];
            for (var i = 0; i < newData.socProgItemDTOList.length; i++) {
              if (!has.includes(newData.socProgItemDTOList[i].itemName)) {
                has.push(newData.socProgItemDTOList[i].itemName);
              } else {
                this.$message.error("项目名称不允许同名");
                return;
              }
            }
            getShebaoMethod(newData).then((res) => {
              this.$message.success("新建成功！");
              this.$router.go(-1);
            });
          } else {
            if (this.isContainByString("contractAdmin")) {
              this.handleOk();
            } else {
              this.isEnter = true;
            }
          }
        }
      }
    },
    // 判断填写内容是否完全
    judgeError() {
      let flag = true;
      this.shebao.forEach((item, index) => {
        if (item.itemName === "") flag = false;
      });
      this.jijin.forEach((item, index) => {
        if (item.itemName === "") flag = false;
      });
      console.log(this.progName + "/" + this.socCity + "/" + this.socCityName + "/" + this.deductionsDate);
      if (this.progName === "" || this.progName.length > 50) flag = false;
      if (this.socCity === "" || this.socCityName === "") flag = false;
      if (this.deductionsDate === "" || this.deductionsDate === "") {
        flag = false;
      }
      return flag;
    },

    // 有员工使用此参保方案后的弹出框点击确定后的处理
    handleOk() {
      this.isEnter = false;
      const data = {
        updateItem: this.updateItem,
        time: this.time,
        id: this.progId,
        socCity: this.socCity,
        socCityName: this.socCityName,
        progName: this.progName,
        companyId: this.isContainByString("contractAdmin") ? "0" : this.$store.state.hr.companyId,
        deductionsDate: this.deductionsDate,
        socProgItemDTOList: this.shebao.concat(this.jijin),
        onlySocAmount: false,
        payProvidentFund: this.jijinShow,
        serviceCost: this.servercost,
        socAccount: this.socAccount,
        meAccount: this.meAccount,
        pfAccount: this.pfAccount
      };
      var has2 = [];
      for (var j = 0; j < data.socProgItemDTOList.length; j++) {
        if (!has2.includes(data.socProgItemDTOList[j].itemName)) {
          has2.push(data.socProgItemDTOList[j].itemName);
        } else {
          this.$message.error("项目名称不允许同名");
          return;
        }
      }
      changeShebaoMethod(data).then((res) => {
        this.$message.success("保存成功！");
        this.$router.go(-1);
      });
    },
    // 查询参保方案试用月份
    checkProMonth() {
      const data = {
        progId: this.progId
      };
      selectTimeInfoByProgId(data).then((res) => {
        this.timeList = [];
        if (res.data != null) {
          res.data.map((item) => {
            this.timeList.push(item.year + "-" + item.month);
          });
        }
      });
    },
    handleCancel() {
      this.isEnter = false;
    },
    // 查询方案详情
    toInquire() {
      findSocProgRelation({
        progId: this.progId,
        companyId: this.isContainByString("contractAdmin") ? "0" : this.$store.state.hr.companyId
      }).then((res) => {
        this.onlySocAmount = res.data.onlySocAmount;
        this.init(this.onlySocAmount, res);
      });
    },
    // 查询尾数处理
    toWeiShuquire() {
      this.groupList = [];
      toWeiShuquire().then((res) => {
        if (res.data !== null) {
          for (var key in res.data) {
            const h = { id: res.data[key], name: key };
            this.groupList.push(h);
          }
        }
      });
    },
    // 深拷贝，解决引用赋值
    deepCopy(arr) {
      const newArr = [];
      arr.forEach((item, index) => {
        const record = {};
        for (const k in item) {
          record[k] = item[k];
        }
        newArr.push(record);
      });
      return newArr;
    },
    // 根据onlySocAmount初始化组件
    init(flag, res) {
      if (!flag) {
        this.jijinShow = res.data.payProvidentFund;
        this.empCount = res.data.empCount;
        if (this.empCount === null) {
          this.empCount = 0;
        }
        this.shebao = res.data.socProgItemVOSocList;
        if (this.shebao === null) {
          this.shebao = [];
        }
        if (this.shebao != null && this.shebao.length !== 0) {
          if (this.shebao[0].mantissaProcCompany !== undefined) {
            this.groupItemDefault = this.shebao[0].mantissaProcCompany;
          }
          if (this.shebao[0].mantissaProcPersonal !== undefined) {
            this.GgroupItemDefault = this.shebao[0].mantissaProcPersonal;
          }
        }

        this.jijin = res.data.socProgItemVOPfList;
        if (this.jijin === null) {
          this.jijin = [];
        }
        if (this.jijin != null && this.jijin.length !== 0) {
          // 公积金
          if (this.jijin[0].mantissaProcCompany !== undefined) {
            this.groupItemDefault2 = this.jijin[0].mantissaProcCompany;
          }
          if (this.jijin[0].mantissaProcPersonal !== undefined) {
            this.GgroupItemDefault2 = this.jijin[0].mantissaProcPersonal;
          }
        }
      } else {
        this.jijinShow = false;
        this.empCount = 0;
        this.shebao = this.deepCopy(initShebao);
        this.jijin = this.deepCopy(initJijin);
      }

      this.shebao.forEach((item, index) => {
        if (item.defaultType === 101) this.itemChecked.push("101");
        if (item.defaultType === 102) this.itemChecked2.push("102");
        if (item.defaultType === 103) this.itemChecked.push("103");
        if (item.defaultType === 104) this.itemChecked.push("104");
        if (item.defaultType === 105) this.itemChecked2.push("105");
        if (item.defaultType === 106) this.itemChecked.push("106");
        if (item.defaultType === 107) this.itemChecked.push("107");
        if (item.defaultType === 108) this.itemChecked.push("108");
        if (item.defaultType === 109) this.itemChecked.push("109");
        if (item.defaultType === 110) this.itemChecked2.push("110");
        if (item.defaultType === 111) this.itemChecked.push("111");
      });
      if (this.shebao != null && this.shebao.length !== 0) {
        if (this.shebao[0].mantissaProcCompany !== undefined) {
          this.groupItemDefault = this.shebao[0].mantissaProcCompany;
        }
        if (this.shebao[0].mantissaProcPersonal !== undefined) {
          this.GgroupItemDefault = this.shebao[0].mantissaProcPersonal;
        }
      }
      this.itemChecked.forEach((item, index) => {
        this.originChecked[index] = item;
      });
      this.itemChecked2.forEach((item, index) => {
        this.originChecked2[index] = item;
      });

      this.jijin.forEach((item, index) => {
        if (item.defaultType === 106) this.jijinChecked = true;
        if (item.defaultType === 107) this.jijinChecked2 = true;
      });
      if (this.jijin != null && this.jijin.length !== 0) {
        // 公积金
        if (this.jijin[0].mantissaProcCompany !== undefined) {
          this.groupItemDefault2 = this.jijin[0].mantissaProcCompany;
        }
        if (this.jijin[0].mantissaProcPersonal !== undefined) {
          this.GgroupItemDefault2 = this.jijin[0].mantissaProcPersonal;
        }
      }
      this.resort(this.jijin); // 旧方案全部删除后这条代码也删除
      this.shebaoNewList = this.getSheBao(1);
      this.yibaoNewList = this.getSheBao(2);
    },
    // 参保时间选择
    handleTime(e) {
      this.time = e;
    },
    // 是否更新参保人员
    handleChangeInfo(e) {
      if (e.target.value === 1) {
        this.updateItem = false;
        // this.isTimeShow = false;
      } else {
        this.updateItem = true;
        // this.isTimeShow = true;
      }
    }
  }
};
</script>
<style lang="scss" scoped>
.totalBox3 {
  display: flex;
  justify-content: flex-end;
  margin-top: 30px;

  .company {
    margin-right: 24px;
  }
  .shebaoTotal {
    margin-right: 24px;
  }
  .text {
    font-size: 14px;
  }
  .number {
    color: var(--primary);
    font-size: 14px;
  }
}
.totalBox2 {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 100px;

  .company {
    margin-right: 24px;
  }
  .shebaoTotal {
    margin-right: 24px;
  }
  .text {
    font-size: 14px;
  }
  .number {
    color: var(--primary);
    font-size: 14px;
  }
}
.totalBox {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 20px;
  margin-top: 30px;

  .company {
    margin-right: 24px;
  }
  .shebaoTotal {
    margin-right: 24px;
  }
  .text {
    font-size: 14px;
  }
  .number {
    color: var(--primary);
    font-size: 14px;
  }
}
.title-info-tishi {
  font-size: 14px;
  color: #a6a8b4;
  margin-bottom: 24px;
}

.header-title {
  display: flex;
  height: 30px;
  padding-top: 3px;
  padding-top: 5px;
  margin-top: 24px;
  margin-bottom: 5px;
  // background: #fa2855;
  .title-info {
    font-size: 16px;
    color: #252525;
    width: 200px;
    height: 22px;
    margin-right: 10px;
    font-weight: 700;
    padding-left: 15px;
  }

  .title-info:before {
    content: "";
    position: absolute;
    left: 0;
    top: 6px;
    bottom: auto;
    right: auto;
    height: 20px;
    width: 3px;
    background-color: var(--primary);
  }
}
.header-title-box {
  margin-top: 24px;
  margin-bottom: 5px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  .headerTitle {
    display: flex;
    justify-content: flex-start;
    .block {
      width: 3px;
      height: 20px;
      background-color: var(--primary);
      margin-right: 12px;
      margin-top: 2px;
    }
    .title-info {
      font-size: 16px;
      color: #252525;

      font-weight: 700;
    }
  }
}
.totalBox {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 20px;
  margin-top: 30px;

  .company {
    margin-right: 24px;
  }
  .shebaoTotal {
    margin-right: 24px;
  }
  .text {
    font-size: 14px;
  }
  .number {
    color: var(--primary);
    font-size: 14px;
  }
}
.submit-btn {
  display: flex;
  justify-content: center;
  button {
    margin-right: 10px;
  }
}

.addCursor {
  cursor: pointer;
}

.checkboxWrapper {
  position: absolute;
  z-index: 999;
  background-color: #fff;
  width: 200px;
  border-radius: 4px;
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.2);
  padding: 10px 0 10px 10px;
}
</style>
